<template>
	<view class="pages-box rel">
		<!-- #ifndef H5 -->
		<uni-nav-bar :fixed="true" :shadow="false" :statusBar="true" title="充值记录" leftIcon="icon-left"
			color="#ffffff" :backgroundColor="primaryColor">
		</uni-nav-bar>
		<view :style="{height:`${configInfo.navBarHeight}px`}"></view>
		<!-- #endif -->
		<view class="space-lg"></view>
		<view class="mb-md fill-base radius-16 ml-lg mr-lg pb-lg pl-lg pr-lg" v-for="(item,index) in list.data" :key="index">
			<view class="flex-y-center f-paragraph c-title h-88 b-1px-b">充值编号：{{item.order_code}}</view>
			<view class="pt-md">
				<text class="f-desc c-paragraph">支付方式：</text>
				<text class="f-paragraph">{{payModel[item.pay_model]}}</text>
			</view>
			<view class="pt-md">
				<text class="f-desc c-paragraph">支付状态：</text>
				<text class="f-paragraph">{{item.status == 1 ? '支付失败' :'支付成功'}}</text>
			</view>
			<view class="pt-md">
				<text class="f-desc c-paragraph">支付时间：</text>
				<text class="f-paragraph">{{$util.formatTime(item.create_time*1000, '')}}</text>
			</view>
			<view class="pt-md">
				<text class="f-desc c-paragraph">支付金额：</text>
				<text class="f-title text-bold c-warning">￥{{item.price}}</text>
			</view>
		</view>
		<abnor v-if="!loading&&list.data.length<=0&&list.current_page==1"></abnor>
		<view class="space-footer"></view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapMutations
	} from "vuex"
	import siteInfo from '@/siteinfo.js';
	let timer = null
	export default {
		data() {
			return {
				isLoad: false,
				list: {
					data: []
				},
				param: {
					page: 1
				},
				payModel: {
					1: '微信支付',
					2: '支付宝支付'
				},
				loading: true
			}
		},
		computed: mapState({
			primaryColor: state => state.config.configInfo.primaryColor,
			subColor: state => state.config.configInfo.subColor,
			configInfo: state => state.config.configInfo
		}),
		async onLoad(options) {
			this.$util.showLoading()
			this.initIndex()
		},
		async onPullDownRefresh() {
			// #ifndef APP-PLUS
			uni.showNavigationBarLoading()
			// #endif
			this.initRefresh();
			uni.stopPullDownRefresh()
		},
		async onReachBottom() {
			if (this.list.current_page >= this.list.last_page || this.loading) return;
			this.$util.showLoading()
			this.loading = true
			this.param.page += 1
			await this.getList() 
		},
		methods: {
			...mapActions(['getConfigInfo']),
			...mapMutations(['updatePoolItem', 'updateHomeItem']),
			async initIndex(refresh = false){
				if(!this.configInfo.id || refresh){
					this.getConfigInfo()
				}
				this.getList()
			},
			async initRefresh(){
				this.$util.showLoading()
				this.param.page = 1
				this.initIndex(true)
			},
			async getList(){
				let {
					param,
					list: oldList
				} = this
				let newList = await this.$api.user.rechargeOrderList()
				if (param.page == 1) {
					this.list = newList;
				} else {
					newList.data = oldList.data.concat(newList.data)
					this.list = newList;
				}
				this.isLoad = true
				this.loading = false
				this.$util.hideAll()
			},
			async submit(id){}
		},
	}
</script>


<style lang="scss">
	.pages-box {
		
	}
</style>
